<html>
<head><meta charset="utf-8"><title>The µarch/assembler/lang triple-bind · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html">The µarch/assembler/lang triple-bind</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225065421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225065421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225065421">(Feb 03 2021 at 19:10)</a>:</h4>
<p>So, one of the thing that has become apparent is that we are in a triple bind between three "opponents":</p>
<ol start="0">
<li>The Rust language itself, of course</li>
<li>The assembler backend</li>
<li>The instruction set architectures, including even</li>
<li>(but it's 2 again) each µarch of an ISA, which may have different execution characteristics, which <strong>matter</strong> since we're trying to provide <strong>execution power</strong></li>
</ol>



<a name="225065673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225065673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225065673">(Feb 03 2021 at 19:12)</a>:</h4>
<p>We can't stress over every single piece of silicon in existence, but e.g. the divide between Intel and AMD implementations of the same x64 SIMD instructions really do matter a lot since those are quite different in execution characteristics, even to the point of supporting different sets of SIMD ISAs!</p>



<a name="225066407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225066407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225066407">(Feb 03 2021 at 19:17)</a>:</h4>
<p>I mention this because we kind of vomited out listings of our various obstacles and ideas for dealing with them over the past few months, and I think it is valuable if we begin carefully enumerating not just what constraints we are under but also <strong>where those constraints come from</strong> and keeping in mind what currently can satisfy at least <strong>some</strong> of the constraints, in order to keep making headway.</p>



<a name="225067320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225067320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225067320">(Feb 03 2021 at 19:21)</a>:</h4>
<p>This is sort of the obverse of the <a href="#narrow/stream/257879-project-portable-simd/topic/Using.20multiple.20feature.20gates/near/225063804">using multiple feature gates thread</a>, which is about how to divide and conquer sets of obstacles: our sets of obstacles and the way we solve them are unlikely to be "solve all of the µarch problems at once" or even "solve a subset of the µarch problems specifically" but rather "identify a problem from each obstacle and devise a solution that allows us to carve out those problems and address them separately". But that means maintaining a relatively clear-eyed view of the sources of our obstacles per se, in and of themselves, or we'll confuse climbing one peak with the entire mountain range.</p>



<a name="225068866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225068866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225068866">(Feb 03 2021 at 19:32)</a>:</h4>
<p>"this should be a blogpost" MAYBE</p>



<a name="225077212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225077212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225077212">(Feb 03 2021 at 20:34)</a>:</h4>
<p>For instance, based on my understanding:<br>
Supporting "only" SSE means we "only" have to support 128-bit vectors.<br>
NEON introduces 64-bit vectors on the lower end.  AVX extends that to 256. AVX512 extends that to 512.<br>
SVE extends that to potentially 2048(!)... in 128-bit increments.<br>
All of these are architecture-driven concerns.<br>
Const generic types, arrays vs. tuples in repr(simd), etc. are language-driven.</p>
<p>That SVE and AVX512 use bitmask predicates while NEON (and AVX?) use fullmasks is an architecture-driven concern.<br>
Handling that w/ different mask types, opaqueness, traits, layouts, const generics or not, is language-driven.<br>
A lot of the optimization concerns around them are between the assembler and the architecture.</p>



<a name="225078615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225078615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225078615">(Feb 03 2021 at 20:44)</a>:</h4>
<p>I'm assuming that we're conveniently assuming x86 MMX doesn't exist...</p>



<a name="225079089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225079089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225079089">(Feb 03 2021 at 20:48)</a>:</h4>
<p>LA LA LA I CAN'T HEAR YOU</p>



<a name="225082271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225082271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225082271">(Feb 03 2021 at 21:09)</a>:</h4>
<p>OK but seriously the architecture supporting insane instructions which just utterly explode even when you compile to them because they're really hard to use properly even if you're a compiler who can control the entire program is part of the problem, yes.</p>
<p>Especially given that later revisions of that architecture... decoded those instructions slightly differently.</p>



<a name="225103550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225103550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225103550">(Feb 04 2021 at 00:23)</a>:</h4>
<p>This thread is equal parts enticing and terrifying.</p>



<a name="225103772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225103772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225103772">(Feb 04 2021 at 00:26)</a>:</h4>
<p>I have not much to add except probably trying to talk to Sylvain Corlay who built the xsimd library for many of these shenanigans for C++, see here <a href="https://xsimd.readthedocs.io/en/latest/api/instr_macros.html">https://xsimd.readthedocs.io/en/latest/api/instr_macros.html</a></p>



<a name="225104026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225104026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225104026">(Feb 04 2021 at 00:29)</a>:</h4>
<p>We're admittedly being <em>slightly</em> insane here and trying to get ahead of the game re: SVE, the likely-inevitable Intel AVX1024, etc.</p>



<a name="225121127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225121127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225121127">(Feb 04 2021 at 05:34)</a>:</h4>
<p>Gotcha. I take it that besides some logical, shuffling, loading and masking ops, we only have basic arithmetic operations in <code>stdsimd</code> so far right?<br>
It's... a bit much to even keep track of how many different SIMD instructions there are.<br>
(Lists appreciated.)</p>



<a name="225121399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225121399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225121399">(Feb 04 2021 at 05:40)</a>:</h4>
<p>At the moment we basically have arithmetic functions and some version of masking, and we need to implement other things. A lot of holdup has been "wait how do we want to do masking exactly?" since that has been sort of a thing on which a lot of API will depend. <br>
API docs are available here <a href="https://rust-lang.github.io/stdsimd/core_simd/">https://rust-lang.github.io/stdsimd/core_simd/</a><br>
Every vendor has their own list of SIMD intrinsic functions, which are specialized functions that compile to reasonably specific assembly instructions.<br>
Most of Intel's Intrinsics: <a href="https://software.intel.com/sites/landingpage/IntrinsicsGuide/">https://software.intel.com/sites/landingpage/IntrinsicsGuide/#</a><br>
Arm's Neon Intrinsics: <a href="https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics">https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics</a></p>



<a name="225126411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225126411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225126411">(Feb 04 2021 at 07:21)</a>:</h4>
<p>avx4096 or bust</p>



<a name="225126478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225126478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225126478">(Feb 04 2021 at 07:22)</a>:</h4>
<p>see, the funny thing is that AVX1024 was actually threatened by Intel! ...9 years ago.</p>



<a name="225126611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225126611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225126611">(Feb 04 2021 at 07:24)</a>:</h4>
<p>perhaps they will implement it right after they move on from the 14nm process.</p>



<a name="225212666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/The%20%C2%B5arch/assembler/lang%20triple-bind/near/225212666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/The.20.C2.B5arch.2Fassembler.2Flang.20triple-bind.html#225212666">(Feb 04 2021 at 19:49)</a>:</h4>
<p>Ah this is the kind of thing I am thinking of also, <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0349r0.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0349r0.pdf</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>